/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.srcptit.trainning.longph.b2;

import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.nio.Buffer;
import java.util.Scanner;
import java.util.StringTokenizer;

/**
 *
 * @author Long
 */
public class B1 {

    public static void main(String[] args) throws FileNotFoundException, IOException {
        String s = "chao tat ca cac ban";
        String s1 = "chao ban Long";
        System.out.println(s.length());
        System.out.println(s.substring(6));
        System.out.println(s.toLowerCase());
        System.out.println(s.toUpperCase());
        System.out.println(s1.equals(s));
        String s2 = s1.replace(s1, "chao ban Huong");
        System.out.println(s1);
        StringTokenizer a = new StringTokenizer(s1);
        String xau = a.nextToken();
        String xau2 = a.nextToken();
        System.out.println(xau);
        System.out.println(xau2);
        xau = a.nextToken();
        System.out.println(xau);
        while (a.hasMoreTokens()) {
            System.out.println("" + xau);
            xau = a.nextToken();
        }
        System.out.println(s.indexOf(" "));
        System.out.println(s.lastIndexOf(" "));
        Scanner sc = new Scanner(System.in);
        StringBuffer ss = new StringBuffer(s1);
        System.out.println(ss);
        System.out.println(ss.reverse());
        s1 = s1 + " " + s2;
        System.out.println(s1);
        ss.append(" " + s2);
        System.out.println(ss);
        //for(int i=0;i<a.length;i++)        
        // System.out.println(a[i]);
        int k = 123;
        float m = Float.parseFloat(k + "");
        System.out.println(m);
        float t = 0;
        int kt = 0;
        while (kt == 0) {
            try {
                Scanner scan = new Scanner(System.in);
                int h;
                h = scan.nextInt();
                t = Float.parseFloat(h + " ");
                kt = 1;
            } catch (Exception e) {
                System.out.println("Nhap lai ");
                kt = 0;
            };
        }
        System.out.println(t);
    int k1 = 0;
        while(true){
        try {
            k1 = sc.nextInt();
            if(k1>100)throw new NumberFormatException();
        }
        catch(NumberFormatException e){
            continue;
        };
        break;
    }
        DataOutputStream P1=new DataOutputStream(new FileOutputStream("long1.txt"));
        BufferedWriter P=new BufferedWriter(new FileWriter ("long.txt"));
        //ObjectOutputStream P2=new DataOutputStream(new FileOutputStream("long2.txt"));
        
}
}
